package com.spic.business.train.courseware.service.impl;

import com.spic.business.common.datascope.anotation.BusinessDataScope;
import com.spic.business.train.courseware.domain.TrainCourseware;
import com.spic.business.train.courseware.mapper.TrainCoursewareMapper;
import com.spic.business.train.courseware.service.ITrainCoursewareService;
import com.spic.common.core.utils.DateUtils;
import com.spic.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 培训课件Service业务层处理
 * 
 * @author spic
 * @date 2021-10-15
 */
@Service
public class TrainCoursewareServiceImpl implements ITrainCoursewareService 
{
    @Autowired
    private TrainCoursewareMapper trainCoursewareMapper;

    /**
     * 查询培训课件
     * 
     * @param id 培训课件主键
     * @return 培训课件
     */
    @Override
    public TrainCourseware selectTrainCoursewareById(String id)
    {
        return trainCoursewareMapper.selectTrainCoursewareById(id);
    }

    /**
     * 查询培训课件列表
     * 
     * @param trainCourseware 培训课件
     * @return 培训课件
     */
    @Override
    @BusinessDataScope( menuPath = "business/train/courseware/index")
    public List<TrainCourseware> selectTrainCoursewareList(TrainCourseware trainCourseware)
    {
        return trainCoursewareMapper.selectTrainCoursewareList(trainCourseware);
    }

    /**
     * 新增培训课件
     * 
     * @param trainCourseware 培训课件
     * @return 结果
     */
    @Override
    public int insertTrainCourseware(TrainCourseware trainCourseware)
    {
        trainCourseware.setCreateTime(DateUtils.getNowDate());
        return trainCoursewareMapper.insertTrainCourseware(trainCourseware);
    }

    /**
     * 修改培训课件
     * 
     * @param trainCourseware 培训课件
     * @return 结果
     */
    @Override
    public int updateTrainCourseware(TrainCourseware trainCourseware)
    {
        return trainCoursewareMapper.updateTrainCourseware(trainCourseware);
    }

    /**
     * 批量删除培训课件
     * 
     * @param ids 需要删除的培训课件主键
     * @return 结果
     */
    @Override
    public int deleteTrainCoursewareByIds(String[] ids)
    {
        return trainCoursewareMapper.deleteTrainCoursewareByIds(ids);
    }

    /**
     * 删除培训课件信息
     * 
     * @param id 培训课件主键
     * @return 结果
     */
    @Override
    public int deleteTrainCoursewareById(String id)
    {
        return trainCoursewareMapper.deleteTrainCoursewareById(id);
    }

    @Override
    public List<TrainCourseware> selectTrainByIds(List<String> ids) {
        return trainCoursewareMapper.selectBatchIds(ids);
    }
    @Override
    public List<String> selectUrlByIds(List<String> coursewareIds){
        return trainCoursewareMapper.selectUrlByIds(coursewareIds);
    }
}
